package taller2.controller.modes;

import java.awt.event.MouseEvent;

import javax.swing.JOptionPane;

import taller2.utils.Point;
import taller2.view.draws.DrawingArea;
import taller2.view.draws.GraphDrawer;

public class AddTagMode implements Mode{
	
	// pressing the mouse button checks if there is a Node close enough
	// and selects it, to start moving it (but only if no other one is selected)
	public void whenPressed(MouseEvent arg0,DrawingArea area) {
		GraphDrawer drawer = area.getDrawer();
		
		Point initMouse = new Point(arg0.getX(),arg0.getY());
		if(drawer.selectCloseByNode(initMouse)){
			area.repaint();
			String tag = JOptionPane.showInputDialog ("Enter node tag: "); 
			drawer.changeTagForSelectedNode(tag);
		}
		
		drawer.unselectNode();
		area.repaint();
	}

	public void whenReleased(MouseEvent arg0,DrawingArea area) {}

	public void whenDragged(MouseEvent arg0,DrawingArea area) {}
}
